<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组</title>
    <script src="../js/jquery-3.1.1.min.js"></script>
    <script>
        window.onload = function (){
            //定义一个一维数组 冒泡排序
            var mya = [1,5,2,88,3,5,9,34,65,6];
            for (var i=0 ; i<mya.length ;i++){
                var flag = false;
                for (var j=0 ; j<mya.length-i-1 ; j++){
                    var temp;
                    if (mya[j]>mya[j+1]){
                        temp = mya[j];
                        mya[j] = mya[j+1];
                        mya[j+1] = temp;
                        flag = true;
                    }
                }
                if (!flag){
                    break;
                }
            }
            //遍历
            for (var i=0 ; i<mya.length ;i++){
                document.getElementById("number").innerHTML += mya[i] +'&nbsp;';
            }

        };
    </script>
</head>
<body>
    <div id="number"></div>
</body>
</html>